namespace Radar.Test
{
    using Moq;
    using NUnit.Framework;

    [TestFixture]
    public class SimpleFactoryBuilderTest
    {
        private class C<T> where T : class { }

        private IFactoryBuilder builder;
        private IocConfiguration configuration;
        private Mock<IContainer> container;

        [SetUp]
        public void SetUp()
        {
            container = new Mock<IContainer>();
            configuration = new IocConfiguration(container.Object);

            builder = new SimpleFactoryBuilder(typeof(object), container.Object, configuration);
        }

        [Test]
        public void WillMakeSimpleType()
        {
            var f = builder.GetFactoryMethod();
            var x = f(new ResolveContext());

            Assert.That(x, Is.InstanceOf<object>());
        }

        [Test, ExpectedException(typeof(IocConfigurationException))]
        public void WillThrowOnGenericType()
        {
            new SimpleFactoryBuilder(typeof(C<>), container.Object, configuration);
        }
    }
}